<%@ page import="com.jr.entry.User" %><%--
  Created by IntelliJ IDEA.
  User: 75880
  Date: 2024/8/17
  Time: 22:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>供应商管理系统</title>
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="icon" type="image/png" href="assets/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="assets/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
    <link rel="stylesheet" href="assets/css/amazeui.min.css"/>
    <link rel="stylesheet" href="assets/css/admin.css">
    <link rel="stylesheet" href="assets/css/app.css">
    <style>
        .am-selected-status {
            font-size: 13px;
            color: #999;
        }

        .am-selected {
            width: 100%;
        }

    </style>
    <script type="text/javascript" src="assets/js/jquery.min.js"></script>
    <script>

        const constAccount = sessionStorage.getItem('constAccount');

        //根据账号查找用户信息
        $(document).ready(function () {
            // 根据账号查找用户信息
            $.get("UserController/selectUser", {"account": constAccount}, function (user) {
                $("#11").val(user.account);
                $("#22").val(user.phone);
                if (user.idcardName == '' || user.idcardName == null) {
                    $("#btt").click(function (user) {
                        User();
                        enter();
                        $('#btt').prop('disabled', true);
                    });
                } else {
                    alert("欢迎再次登录系统");
                    $("#33").val(user.idcardName);
                    $("#44").val(user.idcardNo);
                    $("#user-name").val(user.enterpriseName);
                    $("#22").attr("readonly", true);
                    $("#33").attr("readonly", true);
                    $("#44").attr("readonly", true);
                    $.get("UserController/selectenter", {"account": constAccount}, function (enterprise) {
                        $("#user-email").val(enterprise.email);
                        $("#user-weibo").val(enterprise.SocialUniformCode);
                        $("#user-QQ").val(enterprise.fax);
                        $("#user-weibo2").val(enterprise.address);
                        $("#user-phone").val(enterprise.phone);
                        $("#user-intro").val(enterprise.address);
                      //  delectandshow(enterprise.scale);
                        if (enterprise.scale=="a"){
                            delectandshow("1-19人");
                        }else if (enterprise.scale=="b"){
                            delectandshow("20-50人");
                        }else if (enterprise.scale=="c"){
                            delectandshow("51-100人");
                        }else if (enterprise.scale=="d"){
                            delectandshow("101-200人");
                        }else if (enterprise.scale=="e"){
                            delectandshow("201-500人");
                        }else if (enterprise.scale=="f"){
                            delectandshow("500人以上");
                        }
                        zd(enterprise.name);
                        $("#user-email").attr("readonly", true);
                        $("#user-name").attr("readonly", true);
                        $("#user-weibo").attr("readonly", true);
                        $("#user-QQ").attr("readonly", true);
                        $("#user-weibo2").attr("readonly", true);
                        $("#user-phone").attr("readonly", true);
                        $("#user-intro").attr("readonly", true);
                    });
                }
            });

            // 输入框验证绑定
            $("[name='text1']").on('blur change', function () {
                ckname();
                ck();
            });
            $("[name='text2']").on('blur change', function () {
                ckid();
                ck();
            });
            $("[name='email1']").on('blur change', function () {
                ckemail1();
                ck();
            });
            $("[name='phnoe']").on('blur change', function () {
                ckphone();
                ck();
            });

        });

        // 企业信息回显dqdqdqd
        function enter() {
            alert("首次登录请完成认证");
            var name = $("#user-name").val();
            var email = $("#user-email").val();
            var CodeCode = $("#user-weibo").val();
            var fax = $("#user-QQ").val();
            var phone = $("#user-phone").val();
            var address = $("#user-intro").val();
            var number = $("[name='scale']").val();
             zd(name);
            $.get("UserController/addEnter", {
                "name": name,
                "email": email,
                "CodeCode": CodeCode,
                "fax": fax,
                "phone": phone,
                "address": address,
                "number": number
            }, function (b) {
                if (b) {
                    alert("认证成功");
                    zd();
                    $("#user-email").attr("readonly", true);
                    $("#user-name").attr("readonly", true);
                    $("#user-weibo").attr("readonly", true);
                    $("#user-QQ").attr("readonly", true);
                    $("#user-weibo2").attr("readonly", true);
                    $("#user-phone").attr("readonly", true);
                    $("#user-intro").attr("readonly", true);
                } else {
                    alert("公司或电话号码重复")
                }

            });
        }

        // 用户回显
        function User() {
            var name = $("#33").val();
            var idcardNo = $("#44").val();
            var enterName = $("#user-name").val();
            $.get("UserController/updateUser", {
                "account": constAccount,
                "name": name,
                "idcardNo": idcardNo,
                "enName": enterName
            }, function () {
                $.get("UserController/selectenter", {
                    "account": constAccount,
                    "enterName": enterName
                }, function () {

                    $("#33").attr("readonly", true);
                    $("#44").attr("readonly", true);
                });
            });
        }

        // 判断姓名不超过5个字的汉字
        function ckname() {
            var val = $("[name='text1']").val();
            var vql = /^[\u4e00-\u9fa5]{1,5}$/;
            if (vql.test(val)) {
                $("[name='text1']").next().css("color", "green").text("√");
            } else {
                $("[name='text1']").next().css("color", "#FF0000").text("姓名不超过5个字的汉字");
            }

        }

        // 判断身份证号为18位数字，第18位可填写X（大写）
        function ckid() {
            var val = $("[name='text2']").val();
            var vql = /^\d{17}[\dX]$/;
            if (vql.test(val)) {
                $("[name='text2']").next().css("color", "green").text("√");
            } else {
                $("[name='text2']").next().css("color", "#FF0000").text("身份证号为18位数字，第18位可填写X（大写）");
            }
        }

        // 判断@字符前只可输入字母与数字，@字符后只能以.com与.cn结尾
        function ckemail1() {
            var val = $("[name='email1']").val();
            var vql = /^[A-Za-z0-9]+@[A-Za-z0-9.-]+\.(com|cn)$/;
            if (vql.test(val)) {
                $("[name='email1']").next().css("color", "green").text("√");
            } else {
                $("[name='email1']").next().css("color", "#FF0000").text("@字符前只可输入字母与数字，@字符后只能以.com与.cn结尾");
            }
        }

        // 判断电话号码11位手机号，1开头，第2位为数字3到9，剩余9位为数字0到9
        function ckphone() {
            var val = $("[name='phnoe']").val();
            var vql = /^1[3-9]\d{9}$/;
            if (vql.test(val)) {
                $("[name='phnoe']").next().css("color", "green").text("√");
            } else {
                $("[name='phnoe']").next().css("color", "#FF0000").text("电话号码11位手机号，1开头，第2位为数字3到9，剩余9位为数字0到9");
            }
        }

        // 验证表单的组织事件
        function ck() {
            var isNameValid = $("[name='text1']").next().css("color") === "rgb(0, 128, 0)";
            var isIdValid = $("[name='text2']").next().css("color") === "rgb(0, 128, 0)";
            var isEmailValid = $("[name='email1']").next().css("color") === "rgb(0, 128, 0)";
            var isPhoneValid = $("[name='phnoe']").next().css("color") === "rgb(0, 128, 0)";

            console.log("Name Valid:", isNameValid);
            console.log("ID Valid:", isIdValid);
            console.log("Email Valid:", isEmailValid);
            console.log("Phone Valid:", isPhoneValid);

            if (isNameValid && isIdValid && isEmailValid && isPhoneValid) {
                $('#btt').prop('disabled', false);
            } else {
                $('#btt').prop('disabled', true);
            }
        }

        function delectandshow(number) {
            $("#77").empty();

            $("<span >" + number + "</span>").appendTo("#77");
        }

        //用户名
        function zd() {
            var name = $("#33").val();

            $("#12").text(name);
        }

        <%--<%
            String newUsername = request.getParameter("username");
            if (newUsername != null && !newUsername.isEmpty()) {
                session.setAttribute("username", newUsername);
            }
        %>

                <p>Session username updated to: <%= session.getAttribute("username") %></p >--%>
    </script>
</head>
<body data-type="generalComponents">
<header class="am-topbar am-topbar-inverse admin-header">
    <button class="am-topbar-btn am-topbar-toggle am-btn am-btn-sm am-btn-success am-show-sm-only"
            data-am-collapse="{target: '#topbar-collapse'}"><span class="am-sr-only">导航切换</span> <span
            class="am-icon-bars"></span></button>
    <div class="am-collapse am-topbar-collapse" id="topbar-collapse">
        <ul class="am-nav am-nav-pills am-topbar-nav am-topbar-right admin-header-list tpl-header-list">
            <li class="am-dropdown" data-am-dropdown data-am-dropdown-toggle>
                <a class="am-dropdown-toggle tpl-header-list-link" href="javascript:">
                    <span class="tpl-header-list-user-nick" id="12"></span><span
                        class="tpl-header-list-user-ico"> <img
                        src="assets/img/user01.png"></span>
                </a>
                <ul class="am-dropdown-content">
                    <li><a href="login.jsp"><span class="am-icon-power-off"></span> 退出</a></li>
                </ul>
            </li>
        </ul>
    </div>
</header>
<div class="tpl-page-container tpl-page-header-fixed">
    <div class="tpl-left-nav tpl-left-nav-hover">
        <div class="tpl-left-nav-list">
            <ul class="tpl-left-nav-menu">
                <li class="tpl-left-nav-item">
                    <a href="javascript:" class="nav-link tpl-left-nav-link-list active">
                        <i class="am-icon-wpforms"></i>
                        <span>企业管理</span>
                        <i class="am-icon-angle-right tpl-left-nav-more-ico am-fr am-margin-right tpl-left-nav-more-ico-rotate"></i>
                    </a>
                    <ul class="tpl-left-nav-sub-menu" style="display: block;">
                        <li>
                            <a href="info-certification.jsp" class="active">
                                <i class="am-icon-angle-right"></i>
                                <span>企业信息认证</span>
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="tpl-left-nav-item">
                    <a href="javascript:" class="nav-link tpl-left-nav-link-list">
                        <i class="am-icon-table"></i>
                        <span>供应商管理</span>
                        <i class="am-icon-angle-right tpl-left-nav-more-ico am-fr am-margin-right"></i>
                    </a>
                    <ul class="tpl-left-nav-sub-menu">
                        <li>
                            <script>
                                $(document).ready(function () {
                                    $("#88").click(function (event) {
                                        event.preventDefault(); // 防止默认的跳转行为

                                        var account = $("#11").val(); // 获取 input 的值


                                        var targetUrl = "white-list.jsp?account=" + encodeURIComponent(account);
                                        // 跳转到目标 URL
                                        window.location.href = targetUrl;

                                    })
                                    $("#99").click(function (event) {
                                        event.preventDefault(); // 防止默认的跳转行为
                                        var account = $("#11").val(); // 获取 input 的值
                                        var targetUrl = "black-list.jsp?account=" + encodeURIComponent(account);
                                        // 跳转到目标 URL
                                        window.location.href = targetUrl;

                                    })
                                })

                            </script>
                            <a href="" id="88">
                                <i class="am-icon-angle-right"></i>
                                <span>供应商白名单</span>
                            </a>

                            <a href="" id="99">
                                <i class="am-icon-angle-right"></i>
                                <span>供应商黑名单</span>
                            </a>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
    <div class="tpl-content-wrapper">
        <div class="tpl-content-page-title">
            企业认证
        </div>
        <ol class="am-breadcrumb">
            <li class="am-active"><a style="color: #999999;">企业管理</a></li>
            <li class="am-active">企业信息认证</li>
        </ol>
        <div class="tpl-portlet-components">
            <div class="portlet-title">
                <div class="caption font-green bold">
                    企业管理员认证
                </div>
                <div class="tpl-portlet-input tpl-fz-ml">
                    <div class="portlet-input input-small input-inline">
                        <div class="input-icon right">
                        </div>
                    </div>
                </div>
            </div>
            <div class="tpl-block ">
                <div class="am-g tpl-amazeui-form">
                    <div class="am-u-sm-12 am-u-md-9">
                        <form class="am-form am-form-horizontal">
                            <div class="am-form-group">
                                <label for="user-name" class="am-u-sm-3 am-form-label">登录账号</label>
                                <div class="am-u-sm-9">

                                    <input type="text" id="11" value=constAccount readonly>

                                </div>
                            </div>
                            <div class="am-form-group">
                                <label for="user-email" class="am-u-sm-3 am-form-label">管理员手机号码</label>
                                <div class="am-u-sm-9">
                                    <input type="text" id="22" readonly>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label for="user-phone" class="am-u-sm-3 am-form-label">管理员姓名</label>
                                <div class="am-u-sm-9">
                                    <input type="text" placeholder="请输入管理员姓名" id="33" name="text1"><span></span>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label for="user-QQ" class="am-u-sm-3 am-form-label">管理员身份证号</label>
                                <div class="am-u-sm-9">
                                    <input type="text" placeholder="请入管理员身份证号" id="44" name="text2"><span></span>
                                </div>

                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>

        <div class="tpl-portlet-components">
            <div class="portlet-title">
                <div class="caption font-green bold">
                    企业信息
                </div>
                <div class="tpl-portlet-input tpl-fz-ml">
                    <div class="portlet-input input-small input-inline">
                        <div class="input-icon right">
                        </div>
                    </div>
                </div>
            </div>
            <div class="tpl-block ">
                <div class="am-g tpl-amazeui-form">
                    <div class="am-u-sm-12 am-u-md-9">
                        <form class="am-form am-form-horizontal">
                            <div class="am-form-group">
                                <label for="user-name" class="am-u-sm-3 am-form-label">企业名称</label>
                                <div class="am-u-sm-9">
                                    <input type="text" id="user-name" placeholder="请输入企业名称">
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label for="user-weibo" class="am-u-sm-3 am-form-label">统一社会信用代码</label>
                                <div class="am-u-sm-9">
                                    <input type="text" id="user-weibo" placeholder="请输入统一社会信用代码">
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label for="user-weibo" class="am-u-sm-3 am-form-label">企业规模</label>
                                <div class="am-u-sm-9" id="77">
                                    <select placeholder="请选择企业规模" data-am-selected name="scale" id="66">
                                        <option value="4">请选择企业规模</option>
                                        <option value="a">0-20人</option>
                                        <option value="b">20-50人</option>
                                        <option value="c">50-100人</option>
                                        <option value="d">100-500人</option>
                                        <option value="e">500以上</option>
                                    </select>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label for="user-email" class="am-u-sm-3 am-form-label">企业邮箱</label>
                                <div class="am-u-sm-9">
                                    <input type="email" id="user-email" placeholder="请输入企业邮箱"
                                           name="email1"><span></span>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label for="user-phone" class="am-u-sm-3 am-form-label">企业电话</label>
                                <div class="am-u-sm-9">
                                    <input type="tel" id="user-phone" placeholder="请输入企业电话" name="phnoe"><span></span>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label for="user-QQ" class="am-u-sm-3 am-form-label">传真</label>
                                <div class="am-u-sm-9">
                                    <input type="number" pattern="[0-9]*" id="user-QQ" placeholder="请输入传真">
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label for="user-weibo" class="am-u-sm-3 am-form-label">企业注册地</label>
                                <div class="am-u-sm-9">
                                    <input type="text" id="user-weibo2" placeholder="请企业注册地">
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label for="user-intro" class="am-u-sm-3 am-form-label">企业注册详细地址</label>
                                <div class="am-u-sm-9">
                                    <textarea class="" rows="5" id="user-intro" placeholder="请输入企业注册详细地址"></textarea>
                                    <small>250字以内...</small>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <div class="am-u-sm-9 am-u-sm-push-3">
                                    <button type="button" class="am-btn am-btn-primary" id="btt" name="btt" disabled>提交
                                    </button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/amazeui.min.js"></script>
<script src="assets/js/app.js"></script>

</body>

</html>
